package com.dews.web.controller.train;

import com.dews.common.annotation.Log;
import com.dews.common.core.controller.BaseController;
import com.dews.common.core.domain.BaseResponse;
import com.dews.common.enums.BusinessType;
import com.dews.train.domain.vo.ProgramTeachPlanVo;
import com.dews.train.service.IProgramTeachPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 方案教学计划Controller
 * 
 * @author qingfeng
 * @date 2024-12-22
 */
@Api(value = "方案教学计划", tags = {"方案教学计划" })
@RestController
@RequestMapping("/train/programTeachPlan")
public class ProgramTeachPlanController extends BaseController {

    private IProgramTeachPlanService programTeachPlanService;

    @Autowired
    public ProgramTeachPlanController(IProgramTeachPlanService programTeachPlanService) {
        this.programTeachPlanService = programTeachPlanService;
    }


    @ApiOperation(value = "获取方案教学计划列表")
    @PreAuthorize("@ss.hasPermi('train:programTeachPlan:list')")
    @GetMapping("/list")
    public BaseResponse list(@RequestParam("programId") Integer programId) {
        List<ProgramTeachPlanVo> list = programTeachPlanService.selectProgramTeachPlanList(programId);
        return success(list);
    }

    @ApiOperation(value = "获取方案教学计划详细信息")
    @PreAuthorize("@ss.hasPermi('train:programTeachPlan:query')")
    @GetMapping(value = "/{id}")
    public BaseResponse getInfo(@PathVariable("id") Integer id) {
        return success(programTeachPlanService.selectProgramTeachPlanById(id));
    }

    @ApiOperation(value = "新增方案教学计划")
    @PreAuthorize("@ss.hasPermi('train:programTeachPlan:add')")
    @Log(title = "方案教学计划", businessType = BusinessType.INSERT)
    @PostMapping
    public BaseResponse add(@RequestBody ProgramTeachPlanVo programTeachPlanVo) {
        return toAjax(programTeachPlanService.insertProgramTeachPlan(programTeachPlanVo));
    }

    @ApiOperation(value = "修改方案教学计划")
    @PreAuthorize("@ss.hasPermi('train:programTeachPlan:edit')")
    @Log(title = "方案教学计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public BaseResponse edit(@RequestBody ProgramTeachPlanVo programTeachPlanVo) {
        return toAjax(programTeachPlanService.updateProgramTeachPlan(programTeachPlanVo));
    }

    @ApiOperation(value = "删除方案教学计划")
    @PreAuthorize("@ss.hasPermi('train:programTeachPlan:remove')")
    @Log(title = "方案教学计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public BaseResponse remove(@PathVariable List<Integer> ids) {
        return toAjax(programTeachPlanService.deleteProgramTeachPlanByIds(ids));
    }

    /**
     * 根据专业查询课程列表
     */
    @ApiOperation(value = "根据专业查询课程列表")
    @GetMapping("/getCourseListByProgramId/{programId}")
    public BaseResponse getCourseListByProgramId(@PathVariable("programId") Integer programId) {
        return success(programTeachPlanService.getCourseListByProgramId(programId));
    }


}
